#ifndef __STYLEDBUTTON_H__
#define __STYLEDBUTTON_H__


#include <QtGui/QPushButton>
#include <QtGui/QPixmap>
#include <QtGui/QPainter>
#include <QtCore/QEvent>
#include <QtGui/QHoverEvent>
#include <QtGui/QBitmap>
#include <QtCore/QVector>
/*
PStyledButton allows unlimmited states to a button having an individual look for each state.
PStyledButton has built in constant 5 states (enum BUTTON_STATE):
  state 0: button is not pressed (off) and mouse is not over the button
  state 1: button is not pressed (off_mouseOver) and mouse is over the button
  state 2: button is pressed while being on 
  state 3: button is pressed while being off 
  state 4: button is on (on) and mouse is not over the button (when toggled)
  state 5: button is on (on_mouseOver) and mouse is over the button (when toggled)
  state 6: disabled
These states are handeled by PStyledButton all the user needs to so is asign pixmaps to each state, 
any additional user states need to be implementd by the user but usually it will only require the user 
to call addState() and setState(), since usually only the look of the button will need to change.
*/
class PStyledButton : public QPushButton
{
    Q_OBJECT
    Q_PROPERTY(bool adjustToPixmap READ isAdjustToPixmap WRITE setAdjustToPixmap DESIGNABLE true)
    Q_PROPERTY(unsigned int states READ numStates WRITE setNumStates DESIGNABLE true)
    Q_PROPERTY(QPixmap firstStatePixmap READ getFirstStatePixmap WRITE setFirstStatePixmap DESIGNABLE true)
    Q_PROPERTY(QPixmap maskPixmap READ maskPixmap WRITE setMask DESIGNABLE true )
    Q_PROPERTY(unsigned int startState READ startState WRITE setStartState DESIGNABLE true )
public:
 typedef enum { off=0,off_mouseOver,on_pressed,off_pressed,on,on_mouseOver,disabled }BUTTON_STATE ;
protected:
    int m_state; //holds current state
    //int   m_lastState;
    QVector<QPixmap> m_states;
    bool m_adjustToPixmap;
    QPixmap m_maskPixmap;    
    unsigned int m_startState;
protected:
    virtual void focusInEvent (QFocusEvent* event);
    virtual void focusOutEvent (QFocusEvent* event);
    virtual void setOn (bool on);
public:
    PStyledButton (QWidget* parent, QPixmap *pixmap=0);
    ~PStyledButton ();

    virtual bool event( QEvent* e);
    int state(); // returns the value of m_state
    //defines if the button should adjust its size to the state pixmap
    void setAdjustToPixmap(bool adjust);
    bool isAdjustToPixmap();
    // Sets the current state
    void setState(int state);
    // Adds a new state
    void addState(QPixmap pixmap);
    //Rplace a view of a state
    void replaceStatePixmap(int state,QPixmap pixmap);
    // No description
    void paintEvent(QPaintEvent *e);
    QPixmap getStatePixmap(int state=0);
    void setNumStates(unsigned int numStates);
    void setFirstStatePixmap(QPixmap pixmap);
    QPixmap getFirstStatePixmap();
    unsigned int numStates();
    void setMask(QPixmap maskPixmap);
    QPixmap maskPixmap();
    void setState(BUTTON_STATE state);
    void replaceStatePixmap(BUTTON_STATE state, QPixmap pixmap);
    void setStartState(unsigned int state);
    unsigned int startState();
   
public slots:
    void setDisabled(bool disabled);
    void setEnabled(bool enabled);
};


#endif

	
